<?php include("../components/autoload.php"); ?>
<?php include("../components/functions.php"); ?>
<?php include("../../components/connection.php"); ?>

<?php
	@header('Content-Type: text/html; charset=UTF-8'); 
	
	$player = new Player($_GET['id']);
	
	if(file_exists('../../media/players/'.$player->slika)) {
		if (unlink ('../../media/players/'.$player->slika)) echo "Slika obrisana!<br />";
	}
	
	if(file_exists('../../media/players/big/'.$player->profilnaSlika)) {
		if (unlink ('../../media/players/big/'.$player->profilnaSlika)) echo "ProfilnaSlika obrisana!<br />";
	}
	
	$q = "DELETE FROM igra_za WHERE igrac = ". $player->id;
	if (mysql_query($q)) echo "Obrisan igrac iz tima!<br />";
	
	$q = "DELETE FROM pozicije WHERE igrac = ". $player->id;
	if (mysql_query($q)) echo "Obrisane pozicije igraca!<br />";
	
	$q = "DELETE FROM statistika WHERE igrac = ". $player->id;
	if (mysql_query($q)) echo "Obrisana statistika igraca!<br />";
	
	$q = "DELETE FROM je_kapiten WHERE igrac = ". $player->id;
	if (mysql_query($q)) echo "Obrisano kapitenstvo igraca!<br />";
	
	$q = "DELETE FROM igrac WHERE id = ". $player->id;
	if (mysql_query($q)) echo "Obrisan igrac!<br />";
	
	unset($player);
	
?>